<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace app\adminapi\validate\setting;

use think\Validate;

class SystemAdminValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'account|登录账号' => 'require|max:55',
        'password|密码' => 'require|max:32',
        'password2|二次密码' => 'require|max:32',
        'realName|实名' => 'require|max:32',
        'phone|手机号' => 'require|mobile',
        'email|邮箱' => 'require|email',
        'agree|同意协议' => 'require|boolean',

        'avatar|头像' => 'require',
        'dept|部门id' => 'require|number',
        'nickname|昵称' => 'require',
        'roleId|角色ids' => 'require|array',
        'sort|排序值' => 'require|number',
        'deleteFlag|删除标识' => ['require', 'in' => '0,1'],
        'status|禁用标识' => ['require', 'in' => '1,2,3'],

        'ids' => 'require|array',

        'prop' => ['in' => ['sort', 'id', 'createTime']],
        'order' => ['in' => ['descending', 'ascending']],
        'filterRole' => 'number'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [];

    /**
     * 验证场景定义
     * @var array
     */
    protected $scene = [
        'applySystemAdmin' => ['account', 'password', 'password2', 'realName', 'phone', 'email', 'agree'],
        'editSystemAdmin' => ['account', 'realName', 'phone', 'email', 'dept', 'nickname', 'roleId', 'sort', 'deleteFlag'],
        'batchDelSystemAdmin' => ['ids'],
        'listSystemAdmin' => ['prop', 'order', 'filterRole']
    ];
}
